<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <p>{{ num }}</p>
      <!-- 如果需要传参，则加上小括号即可 -->
      <button v-on:click="plus(1, 2)">点我+1</button>
      <button v-on:click="minus(3, 4)">点我-1</button>
    </div>

    <script src="../vue.js"></script>
    <script>
      var app = new Vue({
        el: '#app',
        data: {
          num: 0,
        },
        methods: {
          plus(a, b) {
            console.log(a, b);
            // 这里的 this  === app
            this.num++;
          },
          minus(a, b) {
            console.log(a, b);
            this.num--;
          },
        },
      });
    </script>
  </body>
</html>
